#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2023/2/26 22:04
# @Author  : xiaohefei
# @File    : searchpage.py
# @Software: PyCharm
# @Description: 搜索页面对象

from page.webpage import WebPage
from common.readelement import Element


class SearchPage(WebPage):
    def __init__(self, driver):
        super().__init__(driver)
        self.driver = driver
        self.locator = WebPage(self.driver)
        self.imagine = ''
        self.search = Element('search')

    def input_search(self, keywords):
        search_box = self.search["搜索框"]
        print(self.search["搜索框"])
        if self.find_element(search_box):
            self.input_text(search_box, keywords)
        pass

    def get_url(self, url):
        return WebPage(self.driver).get_url(url)

    def click_search(self):
        search_btn = self.search["搜索按钮"]
        self.single_click(search_btn)
        pass

    @property
    def get_source(self):
        return WebPage(self.driver).get_source
